package com.michael.demos.ddd.springboot.ports.in;

import com.michael.demos.ddd.springboot.common.SelfValidating;
import com.michael.demos.ddd.springboot.domains.Account.AccountId;
import com.michael.demos.ddd.springboot.domains.Money;
import lombok.EqualsAndHashCode;
import lombok.Value;

import javax.validation.constraints.NotNull;

public interface SendMoneyUseCase {

    boolean sendMoney(SendMoneyCommand command);


    @Value
    @EqualsAndHashCode(callSuper = false)
    class SendMoneyCommand extends SelfValidating<SendMoneyCommand> {

        @NotNull
        private final AccountId sourceAccountId;

        @NotNull
        private final AccountId targetAccountId;

        @NotNull
        private final Money money;

        public SendMoneyCommand(
                AccountId sourceAccountId,
                AccountId targetAccountId,
                Money money
        ) {
            this.sourceAccountId = sourceAccountId;
            this.targetAccountId = targetAccountId;
            this.money = money;
            this.validateSelf();
        }
    }

}
